<template>
  <div>
    <a-card class="card-header">
      <a-row :gutter="24">
        <a-col :span="3">
          <div class="flex flex-a-c">
            <div style="width:80px">公司名称：</div>
            <a-input placeholder="请输入用户名称"></a-input>
          </div>
        </a-col>
        <a-col :span="3">
          <a-button type="primary" @click="handleSearch">查询</a-button>
        </a-col>
      </a-row>
    </a-card>

    <a-card class="card-content">
      <a-row :gutter="24">
        <a-col>
          <a-button type="primary" @click="handleAdd">新建</a-button>
          <!-- <a-button type="primary" @click="handleAdd">导出</a-button> -->
          <!-- <a-button type="primary" @click="handleAdd">导入</a-button> -->
        </a-col>
      </a-row>
      <br />
      <a-table
        :columns="columns"
        :data-source="tableData"
        :loading="loading"
        :pagination="pagination"
        @change="handleTableChange"
        bordered
        :rowKey="(record, index) => record.id"
      >
        <template slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm
            okText="确定"
            cancelText="取消"
            v-if="tableData.length"
            title="确定删除吗?"
            @confirm="() => handleDelete(record)"
          >
            <a>删除</a>
          </a-popconfirm>
        </template>
      </a-table>
    </a-card>

    <UploadModal ref="modalForm" @ok="uploadOK"></UploadModal>
  </div>
</template>

<script>
import { columns } from "./components/tableConfig";
import { tableMinxins } from "@/unit/mixins/tableMinxins.js";
import UploadModal from "./components/UploadModal";
import api from "@/api/apiServer";

export default {
  components: { UploadModal },
  mixins: [tableMinxins],
  data() {
    return {
      columns,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    // 获取列表数据
    async getList(arg) {
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.pagination.current = 1;
      }
      var params = this.getQueryParams();
      // this.loading = true;
      const res = await api.findListByIdentify(params);
      this.tableData = res.data.data;
      this.pagination.total = res.data.total;
    },
    // 删除
    async handleDelete() {},
    // 上传成功
    uploadOK() {
      this.getList();
    }
  },
};
</script>

<style lang="less" scoped>
.card-header {
  margin: 20px 0;
}
.card-content {
  button {
    margin-right: 20px;
  }
}
</style>
